Skip to content

Image, file output types for functions#1898

Merged
rm-openai merged 1 commit intomainfrom
rm/pr1898
Oct 16, 2025
Merged

Image, file output types for functions#1898
rm-openai merged 1 commit intomainfrom
rm/pr1898

Conversation

@rm-openai
Copy link
Copy Markdown
Collaborator

@rm-openai rm-openai commented Oct 14, 2025

To allow the new output types for image/file, you can now return one of the three new types (or lists of those types, or even a typed dict version). If you use those, we'll convert to the correct tool call output type.

Resolves #1850

@rm-openai rm-openai requested a review from seratch October 14, 2025 23:52
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment thread src/agents/items.py Outdated
@seratch seratch added enhancement New feature or request feature:core labels Oct 15, 2025
@rm-openai rm-openai force-pushed the rm/pr1898 branch 2 times, most recently from a06bdca to 622b76a Compare October 15, 2025 18:04
@rm-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

@rm-openai
Copy link
Copy Markdown
Collaborator Author

@seratch ready for review!

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; I've confirmed the image_url works with data URL too (using the code from local_image.py).

@seratch
Copy link
Copy Markdown
Member

seratch commented Oct 16, 2025

If you want to add data URL example too, something like this works, but it's nice-to-have:

FILEPATH = os.path.join(os.path.dirname(__file__), "media/image_bison.jpg")

def image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
    return encoded_string

@function_tool
def fetch_random_image() -> ToolOutputImage | ToolOutputImageDict:
    """Fetch a random image."""

    print("Image tool called")
    b64_image = image_to_base64(FILEPATH)
    return {
        "type": "image",
        "image_url": f"data:image/jpeg;base64,{b64_image}",
        "detail": "auto",
    }

@weathon
Copy link
Copy Markdown

weathon commented Feb 14, 2026

I am a bit confused how this will work. I tried return a list of PIL images but the model seems did not get them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Images in Function Call Outputs

3 participants